//
//  HDCFFundCell.m
//  HaoDeCaiFu
//
//  Created by 郑开宏 on 2017/10/31.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "HDCFFundCell.h"

@interface HDCFFundCell ()

@property (weak, nonatomic) IBOutlet UILabel *fundName;
@property (weak, nonatomic) IBOutlet UILabel *fundType;
@property (weak, nonatomic) IBOutlet UILabel *yearEarn;
@property (nonatomic, strong) NSDictionary *fundTypeDict;
@property (weak, nonatomic) IBOutlet UILabel *earnType;

@end

@implementation HDCFFundCell

- (NSDictionary *)fundTypeDict{
    if (!_fundTypeDict) {
        self.fundTypeDict = @{@"MM":@"货币型",
                              @"BOND":@"债券型",
                              @"MIXED":@"混合型",
                              @"CP":@"保本型",
                              @"EQ":@"股票型",
                              @"AI":@"另类型",
                              @"INDEX":@"指数型",
                              @"ST":@"分级型",
                              @"UNKNOWN":@"其他"
                            };
    }
    return _fundTypeDict;
}

- (void)setDataDict:(NSDictionary *)dataDict{
    _dataDict = dataDict;
    self.fundName.text = dataDict[@"fundName"];
    NSString *fundCode = dataDict[@"fundCode"];
    NSString *fundType = dataDict[@"fundType"];
    NSString *type = self.fundTypeDict[fundType];
    self.fundType.text = [NSString stringWithFormat:@"%@  %@", fundCode, type];

    if ([dataDict[@"year1"] isKindOfClass:[NSNull class]]) {
        self.yearEarn.text = @"暂无";
    }else{
        NSNumber *year1 = dataDict[@"year1"];
        double ye = year1.doubleValue;
        double yet = ye * 100.0;
        self.yearEarn.text = [NSString stringWithFormat:@"%.2f%%", yet];
    }
//    NSNumber *year1 = dataDict[@"year1"];
//    self.yearEarn.text = [NSString stringWithFormat:@"%.2f%%", year1.doubleValue];

    
//    if (![dataDict[@"year1"] isKindOfClass:[NSNull class]]) {
//        NSNumber *year1 = dataDict[@"year1"];
//        self.yearEarn.text = [NSString stringWithFormat:@"%.2f%%", year1.doubleValue];
//    }
//    else
//    {
//        self.yearEarn.text = @"0.00%";
//    }
    

//    if ([dataDict[@"sevenDaysAnnualizedYield"] isKindOfClass:[NSNull class]]) {
//        if (![dataDict[@"month1"] isKindOfClass:[NSNull class]]) {
//            self.earnType.text = @"近一个月收益";
//            NSNumber *month1 = dataDict[@"month1"];
//            self.yearEarn.text = [NSString stringWithFormat:@"%.3f%%", month1.doubleValue];
//        }else{
//            self.yearEarn.text = @"暂无";
//        }
//        
//    }else{
//        NSNumber *sevenDaysAnnualizedYield = dataDict[@"sevenDaysAnnualizedYield"];
//        self.yearEarn.text = [NSString stringWithFormat:@"%.3f%%", sevenDaysAnnualizedYield.doubleValue];
//    }
    
    
    
}

- (void)setDictTwo:(NSDictionary *)dictTwo{
    _dictTwo = dictTwo;
}

+ (instancetype)HDCFFundCell{
    return [[NSBundle mainBundle] loadNibNamed:@"HDCFFundCell" owner:nil options:nil].firstObject;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
